<template>
	<view>
		<view @tap.stop @tap="hide()" class="models_serve" v-show="state">
			<view class="serve_main">
				<view v-for="(v,i) in list " :key="i" class="serve_list bb">
					<view class="goods ">
						<image class="goodsimg" :src="v.image" mode=""></image>
						<p class=" p20">
							{{v.name}}
						</p>
						<view @tap="openServe(v.productInfo.shippingAddress)" class="goAddress">
							<image class="goAddressIcon" src="../../static/image/daohang@2x.png" mode=""></image>
							{{v.distance}}
						</view>
					</view>
					<view class="topBtn">
						<u-button @tap="jump(v.productInfo.shippingAddress.mobile)" :ripple="true">
							<image src="../../static/image/xinxi@2x.png" mode=""></image>
							联系卖家
						</u-button>
						<u-button @tap="call(v.productInfo.shippingAddress.mobile)" :ripple="true">
							<image src="../../static/image/dianhua@2x.png" mode=""></image>
							拨打电话
						</u-button>
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {mapServe} from '../../tool/index.js'
	import {urls} from '@/api/common.js'
	export default {
		props: ['list'],
		data() {
			return {
				state: false
			}
		},
		methods: {
			show() {
				this.state = true
			},
			hide() {
				this.state = false
			},
			call(mobile) {
				uni.makePhoneCall({
					phoneNumber: mobile
				});
			},
			openServe(e){ 
				mapServe(e.latitude,e.longitude,e.address)
			},
			jump(mobile) {
				if (mobile) {
					// let mpId = plus.runtime.appid
					// var url = 'eper://weichat.xar.com/tochat?mobile=' + mobile+'&mpId=' + mpId;
					// plus.runtime.openURL(url, res => {
					// 	console.log(res);
					// });
					let token = uni.getStorageSync('token')
					let goUrl = `${urls}/#/pages/login/login?mobile=${mobile}&serviceType=集市&token=${token}` 
					 uni.setStorageSync('openWebViewUrl',goUrl)
					let url = `../webView/webView?type=serve`  
					uni.navigateTo({
						url:url
					})
				} else {
					this.$common.msg("请刷新页面重试");
				}
			}
		},

	}
</script>

<style lang="less" scoped>
	@import './index.less';
</style>
